<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * File Uploading Class
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Uploads
 * @author		ExpressionEngine Dev Team
 * @link		http://codeigniter.com/user_guide/libraries/file_uploading.html
 */
class MY_Upload extends CI_Upload
{


	public function set_error($msg, $log_level = 'error')
	{
		$CI =& get_instance();
		$CI->lang->load('upload');

		if (is_array($msg))
		{
			foreach ($msg as $val)
			{
				$msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
				$this->error_msg[] = $msg;
				log_message($log_level, $msg);
			}
		}
		else
		{
			$format_arg = NULL;
			switch($msg)
			{
				case "upload_invalid_filetype":
					$format_arg=array(implode("，",$this->allowed_types));
					break;
				case "upload_invalid_filesize":
					$format_arg=array(Common::format_byte($this->max_size*1024));
					break;
				case "upload_file_exceeds_limit":
					$format_arg=array(Common::format_byte($this->max_size*1024));
					break;
				case "upload_file_exceeds_form_limit":
					$format_arg=array(Common::format_byte($this->max_size*1024));
					break;
			}
			$msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
			if(!empty($format_arg))
			{
				$args =array_merge(array($msg),$format_arg);
				$msg = call_user_func_array("sprintf",$args);
			}

			$this->error_msg[] = $msg;
			log_message($log_level, $msg);
		}
	}
}
// END Upload Class

/* End of file Upload.php */
/* Location: ./system/libraries/Upload.php */
